/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class CustomerLocation
    {
    
        private String userDefinedLocationField;

        private String cityField;

        private String stateField;

        private String countryField;


        /// <summary>
        /// Gets and sets the UserDefinedLocation property.
        /// </summary>
        [XmlElementAttribute(ElementName = "UserDefinedLocation")]
        public String UserDefinedLocation
        {
            get { return this.userDefinedLocationField ; }
            set { this.userDefinedLocationField= value; }
        }



        /// <summary>
        /// Sets the UserDefinedLocation property
        /// </summary>
        /// <param name="userDefinedLocation">UserDefinedLocation property</param>
        /// <returns>this instance</returns>
        public CustomerLocation WithUserDefinedLocation(String userDefinedLocation)
        {
            this.userDefinedLocationField = userDefinedLocation;
            return this;
        }



        /// <summary>
        /// Checks if UserDefinedLocation property is set
        /// </summary>
        /// <returns>true if UserDefinedLocation property is set</returns>
        public Boolean IsSetUserDefinedLocation()
        {
            return  this.userDefinedLocationField != null;

        }


        /// <summary>
        /// Gets and sets the City property.
        /// </summary>
        [XmlElementAttribute(ElementName = "City")]
        public String City
        {
            get { return this.cityField ; }
            set { this.cityField= value; }
        }



        /// <summary>
        /// Sets the City property
        /// </summary>
        /// <param name="city">City property</param>
        /// <returns>this instance</returns>
        public CustomerLocation WithCity(String city)
        {
            this.cityField = city;
            return this;
        }



        /// <summary>
        /// Checks if City property is set
        /// </summary>
        /// <returns>true if City property is set</returns>
        public Boolean IsSetCity()
        {
            return  this.cityField != null;

        }


        /// <summary>
        /// Gets and sets the State property.
        /// </summary>
        [XmlElementAttribute(ElementName = "State")]
        public String State
        {
            get { return this.stateField ; }
            set { this.stateField= value; }
        }



        /// <summary>
        /// Sets the State property
        /// </summary>
        /// <param name="state">State property</param>
        /// <returns>this instance</returns>
        public CustomerLocation WithState(String state)
        {
            this.stateField = state;
            return this;
        }



        /// <summary>
        /// Checks if State property is set
        /// </summary>
        /// <returns>true if State property is set</returns>
        public Boolean IsSetState()
        {
            return  this.stateField != null;

        }


        /// <summary>
        /// Gets and sets the Country property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Country")]
        public String Country
        {
            get { return this.countryField ; }
            set { this.countryField= value; }
        }



        /// <summary>
        /// Sets the Country property
        /// </summary>
        /// <param name="country">Country property</param>
        /// <returns>this instance</returns>
        public CustomerLocation WithCountry(String country)
        {
            this.countryField = country;
            return this;
        }



        /// <summary>
        /// Checks if Country property is set
        /// </summary>
        /// <returns>true if Country property is set</returns>
        public Boolean IsSetCountry()
        {
            return  this.countryField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetUserDefinedLocation()) {
                xml.Append("<UserDefinedLocation>");
                xml.Append(EscapeXML(this.UserDefinedLocation));
                xml.Append("</UserDefinedLocation>");
            }
            if (IsSetCity()) {
                xml.Append("<City>");
                xml.Append(EscapeXML(this.City));
                xml.Append("</City>");
            }
            if (IsSetState()) {
                xml.Append("<State>");
                xml.Append(EscapeXML(this.State));
                xml.Append("</State>");
            }
            if (IsSetCountry()) {
                xml.Append("<Country>");
                xml.Append(EscapeXML(this.Country));
                xml.Append("</Country>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}